package com.xiongwei.manageback.utils;

import cn.hutool.http.HttpStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 通用结果返回类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AjaxResult {
    private String msg;
    private boolean success;
    private Object data;
    private int code;

    public static AjaxResult success(){
        return new AjaxResult(null,true,null,HttpStatus.HTTP_OK);
    }
    public static AjaxResult success(Object data){
        return new AjaxResult(null,true,data,HttpStatus.HTTP_OK);
    }

    public static AjaxResult fail(String msg,int code){
        return new AjaxResult(msg,false,null,code);
    }

    public static AjaxResult fail(String msg){
        return new AjaxResult(msg,false,null,HttpStatus.HTTP_INTERNAL_ERROR);
    }
}
